package com.power.exception.handler;

import com.power.constant.BusinessEnum;
import com.power.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.nio.file.AccessDeniedException;

@RestControllerAdvice
@Slf4j
public class GlobalException {
    @ExceptionHandler(RuntimeException.class)
    public Result handleException(RuntimeException e) {
        log.error("系统异常:{}", e.getMessage());
        return Result.fail(BusinessEnum.SERVER_INNER_ERROR);
    }
    @ExceptionHandler(AccessDeniedException.class)
    public Result handleException(AccessDeniedException e) {
        log.error("系统异常:{}", e.getMessage());
    return Result.fail(BusinessEnum.ACCESS_DENY_FAIL);
    }
}
